package com.dong.thread.threadbasic;

/**
 * Interrupt_and_sleep_wait_join
 *
 * @author by jiweidong on 2021/11/21.
 */
public class T06_Interrupt_and_sleep_wait_join {

    public static void main(String[] args) {
        Thread t = new Thread(() -> {

            try {
                Thread.sleep(4000);
            } catch (InterruptedException e) {
                System.out.println("Thread is interrupted");
                // 注意：catch住InterruptedException异常后，中断标志会自动复位（以免影响接受其他的中断请求）
                System.out.println("interrupted： " + Thread.currentThread().isInterrupted());
            }
        });

        t.start();

        SleepHelper.sleepSeconds(2);

        t.interrupt();

    }
}
